package com.afei.java.ai.langchain4j.config;

import com.afei.java.ai.langchain4j.store.MongoChatMemoryStore;
import dev.langchain4j.memory.chat.ChatMemoryProvider;
import dev.langchain4j.memory.chat.MessageWindowChatMemory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Title: SeparateChatAssisantConfig
 * @Author wangyf
 * @Package com.afei.java.ai.langchain4j.config
 * @Date 2025/4/23 10:41
 * @description:
 */

@Configuration
public class SeparateChatAssisantConfig {

    @Autowired
    private MongoChatMemoryStore mongoChatMemoryStore;

    @Bean
    public ChatMemoryProvider chatMemoryProvider() {

        return memoryId -> MessageWindowChatMemory.builder().id(memoryId).maxMessages(10)
                .chatMemoryStore(mongoChatMemoryStore)
                .build();
    }
}
